#include <stdio.h>
#include <errno.h>

#include "sock.h"

#define PORT 6666

int main(int argc, char **argv)
{
    char * a;
    server_t server = openServer(a, PORT);
    int cFd;
    socklen_t sin_size = sizeof(struct sockaddr_in);
    struct sockaddr_in newConnection;

    while (server.status == 0) {

        printf("Server fd: %d\n", server.fd);
        if ((cFd = accept(server.fd, (struct sockaddr *)&newConnection,
            &sin_size)) == -1) {

            char * mesg = strerror(errno);
            printf("Accept error: %s\n",mesg);

            break;
        }

        newConnect(cFd);

    }

    //close(cFd);
    
    return 0;
}
